<?php
	/*
	 * 发送邮件API
	 */
	 
	date_default_timezone_set('America/Toronto');
	require_once THINKDATA.'/class/PHPMailer/class.phpmailer.php';
	$mail = new PHPMailer();
	
	/*
	 *邮件配置
	 */
	 
	$mail->IsSMTP(); 
	$mail->SMTPDebug  	= 1;
	$mail->SMTPAuth   	= true;           
	$mail->Host       		= $TS_APP['options']['mailhost']; 
	$mail->Port       		= $TS_APP['options']['mailport']; 
	$mail->Username   	= $TS_APP['options']['mailuser']; 
	$mail->Password   	= $TS_APP['options']['mailpwd']; 
	

	//POST过来的信息
	$frommail		= $_POST['frommail'];
	$fromname	= $_POST['fromname'];
	$replymail		= $_POST['replymail'];
	$replyname	= $_POST['replyname'];
	$subject		= $_POST['subject'];
	$content		= $_POST['content'];
	$sendmail		= $_POST['sendmail'];
	$sendname	= $_POST['sendname'];

	if(empty($frommail) || empty($subject) || empty($content) || empty($sendmail)){
		echo '0';
	}else{
	
		/*
		 *邮件发送
		 */
		
		$mail->SetFrom($frommail, $fromname);
		$mail->AddReplyTo($replymail,$replyname);
		$mail->Subject    = $subject;
		$mail->AltBody    = "要查看邮件，请使用HTML兼容的电子邮件阅读器!"; 
		$mail->MsgHTML(eregi_replace("[\]",'',$content));
		$mail->AddAddress($sendmail, $sendname);
		$mail->Send();
		
		echo '1';
		
	}